<template>
  <el-dialog
    title="预览"
    :append-to-body="true"
    :visible.sync="visible"
    :before-close="close"
    :close-on-click-modal="false"
    fullscreen>

    <el-button v-if="!reportAll02Z05Visible" type="success" class="pan-btn success-btn" v-print="'#check'" size="mini">打印</el-button>

    <check-yfb02 v-if="checkYfb02Visible" @close="close('checkYfb02Visible')" :childDataForm="childDataForm" />

    <check-yfb03 v-else-if="checkYfb03Visible" @close="close('checkYfb03Visible')" :childDataForm="childDataForm" />

    <check-yfb04 v-else-if="checkYfb04Visible" @close="close('checkYfb04Visible')" :childDataForm="childDataForm" />

    <check-zc00 v-else-if="checkZc00Visible" @close="close('checkZc00Visible')" :childDataForm="childDataForm" />

    <check-zc01 v-else-if="checkZc01Visible" @close="close('checkZc01Visible')" :childDataForm="childDataForm" />

    <check-ys03 v-else-if="checkYs03Visible" @close="close('checkYs03Visible')" :childDataForm="childDataForm" />

    <report-all02-z-05 v-else-if="reportAll02Z05Visible" @close="close('reportAll02Z05Visible')" :childDataForm="childDataForm" />

    <check-env-01 v-else-if="checkEnv01Visible" @close="close('checkEnv01Visible')" :childDataForm="childDataForm" />

    <Zl-Smp019-R0106 v-else-if="ZLSMP019R0106Visible" @close="close('ZLSMP019R0106Visible')" :childDataForm="childDataForm" />

    <Zl-Smp059-R0301 v-else-if="ZLSMP059R0301Visible" @close="close('ZLSMP059R0301Visible')" :childDataForm="childDataForm" />

    <Zl-Smp059-R0101 v-else-if="ZLSMP059R0101Visible" @close="close('ZLSMP059R0101Visible')" :childDataForm="childDataForm" />

    <Zl-Smp059-R0302 v-else-if="ZLSMP059R0302Visible" @close="close('ZLSMP059R0302Visible')" :childDataForm="childDataForm" />

    <Zl-Smp059-R0102 v-else-if="ZLSMP059R0102Visible" @close="close('ZLSMP059R0102Visible')" :childDataForm="childDataForm" />

    <Zl-Smp019-R0107 v-else-if="ZLSMP019R0107Visible" @close="close('ZLSMP019R0107Visible')" :childDataForm="childDataForm" />


    <h1 v-else>{{ '无此'+this.childDataForm.printClassify+'打印模板，类别:【'+this.childDataForm.checkTypeName+'】,版本号:【'+this.childDataForm.printReportVersion+'】'+'，请联系管理员' }}</h1>

  </el-dialog>
</template>

<script>
  import { isBlank } from '@/common/js/utils'
  import CheckYfb02 from './check/yfb-02'
  import CheckYfb03 from './check/yfb-03'
  import CheckYfb04 from './check/yfb-04'
  // import CheckYfb041 from './check/yfb-041'
  import CheckZc00 from './check/zc-00'
  import CheckZc01 from './check/zc-01'
  import CheckYs03 from './check/ys-03'
  import ReportAll02Z05 from './report/all-02-z-05'
  import CheckEnv01 from './check/env-01'
  import ZlSmp019R0106 from './pass/all-06'
  import ZlSmp059R0301 from './pass/ZL-SMP-059-R03-01'
  import ZlSmp059R0101 from './pass/ZL-SMP-059-R01-01'
  import ZlSmp059R0302 from './pass/ZL-SMP-059-R03-02'
  import ZlSmp059R0102 from './pass/ZL-SMP-059-R01-02'
  import ZlSmp019R0107 from './pass/ZL-SMP-019-R01-07'
  import ZlSmp019R0108 from './pass/ZL-SMP-019-R01-08'
  import ZlSmp064R0100 from './pass/ZL-SMP-064-R01-00'


  import { CODE_OK } from '@/common/js/config'

  export default {
    data() {
      return {
        visible: false,
        checkYfb02Visible: false,
        checkYfb03Visible: false,
        checkYfb04Visible: false,
        checkZc00Visible: false,
        checkZc01Visible: false,
        checkYs03Visible: false,
        reportAll02Z05Visible: false,
        checkEnv01Visible: false,
        ZLSMP019R0106Visible: false,
        ZLSMP059R0301Visible: false,
        ZLSMP059R0101Visible: false,
        ZLSMP059R0302Visible: false,
        ZLSMP059R0102Visible: false,
        ZLSMP019R0107Visible: false,
        ZLSMP019R0108Visible: false,
        ZLSMP064R0100Visible: false
      }
    },
    props: ["childDataForm"],
    components: {
      CheckYfb02,
      CheckYfb03,
      CheckYfb04,
      CheckZc00,
      CheckZc01,
      CheckYs03,
      ReportAll02Z05,
      CheckEnv01,
      ZlSmp019R0106,
      ZlSmp059R0301,
      ZlSmp059R0101,
      ZlSmp059R0302,
      ZlSmp059R0102,
      ZlSmp019R0107,
      ZlSmp019R0108,
      ZlSmp064R0100
    },
    created() {
      if (!isBlank(this.childDataForm)) {
        this.visible = true
        let printNumber = this.childDataForm.printNumber
        let printClassify = this.childDataForm.printClassify
        if(printClassify == '物料放行审核单'){
          if (!isBlank(printNumber)) {
            this[printNumber.replace(/[^a-zA-Z0-9]+/g,'')+'Visible'] = true
          }
        }else{
          if (!isBlank(printNumber)) {
            this[printNumber.replace(/[^a-zA-Z0-9]+/g,'')+'Visible'] = true
            return
          }
          let prop = null
          if (printClassify == '请验单') {
            prop = this.getPrintCheckProp()
          } else if(printClassify == '报告书') {
            prop = this.getPrintReportProp()
          }
          if (prop == null) {
            this.close()
            return
          }
          this[prop] = true
        }
      }
    },
    methods: {
      getPrintReportProp() {
        let prop = null
        let checkTypeId = this.childDataForm.checkTypeId
        let printReportVersion = this.childDataForm.printReportVersion
        //除中间品外全部版本为02或者中间品版本为05
        if ((checkTypeId != 4 && printReportVersion == '02')
        || (checkTypeId == 4 && printReportVersion == '05')) {
          prop = 'reportAll02Z05Visible'
        }
        if (prop == null) {
          let msg = '暂无此'+this.childDataForm.printClassify+'打印模板，类别:【'+this.childDataForm.checkTypeName+'】,版本号:【'+this.childDataForm.printReportVersion+'】'+'，请联系管理员'
          this.$message.error(msg)
        }
        return prop
      },
      getPrintCheckProp() {
        let prop = null
        let checkTypeId = this.childDataForm.checkTypeId
        let printCheckVersion = this.childDataForm.printCheckVersion
        if (this.yfb(checkTypeId) || this.qt(checkTypeId)) {
          prop = 'checkYfb'
        }else if(this.zc(checkTypeId) || this.wk(checkTypeId)) {
          prop = 'checkZc'
        }else if(this.ys(checkTypeId)) {
          prop = 'checkYs'
        }else if(this.env(checkTypeId)) {
          prop = 'checkEnv'
        }
        prop = prop + this.childDataForm.printCheckVersion + 'Visible'
        if (!this.hasOwnProperty(prop)) {
          let msg = '暂无此'+this.childDataForm.printClassify+'打印模板，类别:【'+this.childDataForm.checkTypeName+'】,版本号:【'+this.childDataForm.printCheckVersion+'】'+'，请联系管理员'
          this.$message.error(msg)
          return null
        }else{
          return prop
        }
      },
      close(val) {
        if (val) {
          this[val] = false
        }
        this.visible = false
        this.$emit('close')
      }
    }
  }
</script>

<style>
</style>
